/****************************************************************
*****************************************************************/

#ifndef __JZM_JPEG_T20_DEC_H__
#define __JZM_JPEG_T20_DEC_H__
#include "jzm_vpu.h"
#include <stdint.h>

typedef intptr_t paddr_t;

#define HUFFMIN_LEN		(16)		/* Huffman min table lenth */
#define HUFFBASE_LEN	(64)        /* Huffman base table lenth */
#define HUFFSYM_LEN		(336)       /* Huffman symbol table lenth */
#define QMEM_LEN		(256)       /* Quantization table lenth */
#define YUV420P0C		(0x30)      /* component 0 configure information NBLK<<4| QT<<2| HA<<1| HD */
#define YUV420P1C		(0x07)      /* component 1 configure information NBLK<<4| QT<<2| HA<<1| HD */
#define YUV420P2C		(0x07)      /* component 2 configure information NBLK<<4| QT<<2| HA<<1| HD */
#define YUV420PVH		(0x0a<<16)  /* component vertical/horizontal size of MCU:P3H P3V P2H P2V P1H P1V P0H P0V */
#define JPEG_DEC		(0x1<<3)	/* Work mode for decoder/encoder choose, 0 – work as encoder, 1 – work as decoder */
#define JPGC_RSM		(0x1<<2)    /* JPGC rstart marker enable signal */
#define JPGC_SPEC		(0x0<<1)    /* YUV420 mode */
#define JPGC_UNIV		(0x1<<1)    /* YUV444 or YUV422 mode */
#define JPGC_EN			(0x1)       /* JPGC enable signal */
#define OPEN_CLOCK		(0x1)       /* open the core clock */
#define JPGC_NCOL		(0x2<<4)    /* color numbers of a MCU minus 1,it always 2 for YUV color space */
#define STAT_CLEAN		(0x0)       /* clean the STAT register */
#define CORE_RST		(0x1<<6)    /* JPGC core reset ,high active */
#define JPGC_EFE		(0x1<<8)    /* JPGC EFE source */
#define VRAM_RAWY_BA	(VPU_BASE | 0xF0000)
#define VRAM_RAWC_BA	(VRAM_RAWY_BA + 256)

/*
 * JPEGD_SliceInfo:
 */
typedef struct _JPEGD_SliceInfo {
	paddr_t des_va, des_pa;
    int *regs;
    int *hea;  // -> BASE mem (base.dat) - 9 bits array
    int *heb; // -> SYMB mem (symb.dat) - 8 bits array
    int *huffmin; // -> min values (min.dat)
    int (*qt)[64]; // QT (qdtable.dat)

    int (*hcode)[256]; // -> Huffman simulation mem values (hmem.sim)
    int (*hlen)[256]; // -> Huffman simulation mem values (hmem.sim)
    int *huffenc;
    paddr_t	bsa;
	paddr_t	dst_y;
	paddr_t	dst_c;
}_JPEGD_SliceInfo;

/*
  JPEGD_SliceInit(_JPEGD_SliceInfo *s)
  @param s: slice information structure
 */

void T20_JPEGD_SliceInit(_JPEGD_SliceInfo *s);

#endif// __JZM_JPEG_ENC_H__
